/* Copyright (C) 2010 Fredrique Samuels, fredriquesamuels@gmail.com */

/*
 This program is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation; either version 2 of the License, or
 (at your option) any later version.

 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.

 You should have received a copy of the GNU General Public License
 along with this program; if not, write to the Free Software
 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#ifndef TRI_MATERIAL_H_
#define TRI_MATERIAL_H_

#include <string>
#include <map>

#include "texture.h" 
#include "graphics.h"


namespace tri {
class TMaterial{
public:
	TMaterial();
	virtual ~TMaterial();

	void setColor(int r,int g, int b,int a);
	void setColor(tri::graphics::RGBA rgba);
	void setTargetColor(tri::graphics::RGBA rgba,float t = 1.0);
	tri::graphics::RGBA getColorAsRGBA();
	tri::graphics::TColor getColor();
	void setSpecular(tri::graphics::RGBA rgba);
	void setShininess(float s);
	void apply();
	
	void setImage(std::string image,bool filter=false,bool mipmap=false);
	std::string getImage();
	bool isImageFiltered();
	bool isImageMipmap();
	tri::TTexture* getTexture();
	
	static void createMaterial(std::string key);
	static bool materialExists(std::string key);
	static void deleteMaterial(std::string key);
	static TMaterial* getMaterial(std::string key);
	
private:
	std::string mImage;
	bool mFilter;
	bool mMipmap;
	
	tri::graphics::TColor mColor;
	GLfloat mSpecular[4];
    GLfloat mShininess[1];
    
    static std::map<std::string,TMaterial*> mMaterialMap;
};



}

#endif /*TRI_GLYPH_H_*/
